package huawei_nowcoder;

import java.util.Scanner;

/**
 * @order 5
 * @decription 进制转换
 */
public class Transform {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            String str = scanner.nextLine();
            char[] chars = str.toCharArray();
            int length = chars.length;
            int[] ints = new int[length];//int数组
            for (int i = 0; i < length; i++) {
                switch (chars[i]) {
                    case 'A':
                    case 'a':
                        ints[i] = 10;
                        break;
                    case 'B':
                    case 'b':
                        ints[i] = 11;
                        break;
                    case 'C':
                    case 'c':
                        ints[i] = 12;
                        break;
                    case 'D':
                    case 'd':
                        ints[i] = 13;
                        break;
                    case 'E':
                    case 'e':
                        ints[i] = 14;
                        break;
                    case 'F':
                    case 'f':
                        ints[i] = 15;
                        break;
                    default:
                        ints[i] = chars[i] - '0';

                }
            }


            //int数组倒叙
            int[] reverse = new int[length];
            for (int i = 0; i < length; i++) {
                reverse[i] = ints[length - i - 1];
//                System.out.println(i + "位数为" + reverse[i]);
            }
            int total = 0;
            for (int i = 0; i < length - 2; i++) {
                total += Math.pow(16, i) * reverse[i];
            }
//            System.out.println("十进制数为"+total);
            System.out.println(total);
        }
    }
}
